Skip to content

refactor: make StrCpy extensible#8

Merged
idleberg merged 3 commits intomainfrom
feat/UnsafeStrCpy
Jan 6, 2026
Merged

refactor: make StrCpy extensible#8
idleberg merged 3 commits intomainfrom
feat/UnsafeStrCpy

Conversation

@idleberg
Copy link
Member

@idleberg idleberg commented Jan 5, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the StrCpyInstruction class to support extensibility through inheritance, enabling the creation of specialized instruction variants like UnsafeStrCpyInstruction. The refactoring introduces a protected constructor that accepts a custom instruction name parameter, allowing subclasses to override the instruction name while reusing the core logic.

Key changes:

  • Introduced extensible design pattern with protected constructor accepting instruction name parameter
  • Created UnsafeStrCpyInstruction as the first subclass demonstrating the extensibility
  • Fixed a typo in return value validation (changed returns != 11 to returns != 1)

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/nsl/instruction/StrCpyInstruction.java Refactored to support extensibility by adding a protected instructionName field and a protected constructor accepting a custom instruction name, while maintaining backward compatibility through constructor chaining
src/nsl/instruction/UnsafeStrCpyInstruction.java New instruction class extending StrCpyInstruction with custom name "UnsafeStrCpy", demonstrating the extensibility pattern
src/nsl/statement/Statement.java Registered the new UnsafeStrCpyInstruction in the instruction matching logic in alphabetical order
examples/Test.nsl Removed temporary test file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@kichik kichik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@idleberg idleberg merged commit 6a9e2be into main Jan 6, 2026
10 checks passed
@idleberg idleberg deleted the feat/UnsafeStrCpy branch January 6, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants